package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.entity.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * dao接口
 */
public interface BrandMapper extends BaseMapper<Brand> {

    /**
     * 批量插入分类与品牌的中间表
     * @param brandId   品牌id
     * @param cids      分类集合
     * @return          返回条数
     */
    int insertBrandCategory(@Param("bid") Long brandId,@Param("cids") List<Long> cids);

    /**
     * 根据分类id查询品牌
     * @param cid 分类id
     * @return
     */
    @Select("SELECT  b.* FROM tb_category_brand cb INNER JOIN tb_brand b ON cb.`brand_id`=b.`id` WHERE cb.`category_id` = #{cid} ")
    List<Brand> queryBrandByCategoryId(@Param("cid") Long cid);
}
